	@include('admin.head')
	<div class="container">
		<div class="row">
			@include('admin.side')
		<div class="col-md-10" id="content-wrapper">
			<ul class="nav nav-tabs">
			  <li class="active"><a href="#home" data-toggle="tab" aria-expanded="true">首页</a></li>
			  <li class=""><a href="#industry" data-toggle="tab" id="showIndustry" aria-expanded="true">低碳产业</a></li>
			  <li class=""><a href="#interactive" data-toggle="tab" id="showInteractive" aria-expanded="true">交互式</a></li>
			</ul>
			<div id="myTabContent" class="tab-content">
			  	<!--首页-->
			  	<div class="tab-pane fade active in" id="home">
			    	<div class="panel panel-default">
						<div class="panel-body">
							<div class="form-horizontal">
							    <div class="form-group">
							      <label class="col-xs-4 control-label no_padding_right">链接:</label>
							      <div class="col-xs-4 save_home_href">
							        <input class="form-control input_size save_home_href" name="link" placeholder="" type="text">
							      </div>
							    </div>
							    <div class="form-group">
							      <label class="col-xs-4 control-label no_padding_right">图片:</label>
							      <div class="col-xs-4">
							            <input type="file" name="imgFile" class="uploadImage">
							            <input type="hidden" class="hiddenName" name="image" value="0">
							        	<span class="fileName"></span>
							      </div>
							    </div>
							    <div class="form-group">
							      <label class="col-xs-4 control-label no_padding_right">排序:</label>
							      <div class="col-xs-4">
							        <input class="form-control input_size save_home_order" name="order" placeholder="" type="text">
							      </div>
							    </div>
					        	<div class="form-group">
					    	      <div class="col-xs-12 text-center">
					    	      	<input type="hidden" name="bid">
					    	        <button type="button" id="addIndexBanner" class="btn btn-primary "> 提 交 </button>
					    	      </div>
					    	    </div>
							</div>
							<div class="main-box">
								<h2></h2>
								<div id="gallery-photos-wrapper">
									<div class="form-horizontal" id="indexBannerList">
									</div>
								</div>
							</div>
						</div>
					</div>
			  	</div>
			  	<!-- 低碳产业 -->
		  	  	<div class="tab-pane fade" id="industry">
		  	    	<div class="panel panel-default">
		  				<div class="panel-body">
		  					<div class="form-horizontal">
		  					    <div class="form-group">
		  					      <label class="col-xs-4 control-label no_padding_right">链接:</label>
		  					      <div class="col-xs-4 save_home_href">
		  					        <input class="form-control input_size save_home_href" name="link" placeholder="" type="text">
		  					      </div>
		  					    </div>
		  					    <div class="form-group">
		  					      <label class="col-xs-4 control-label no_padding_right">图片:</label>
		  					      <div class="col-xs-4">
		  					            <input type="file" name="imgFile" class="uploadImage">
		  					            <input type="hidden" class="hiddenName" name="image" value="0">
		  					        	<span class="fileName"></span>
		  					      </div>
		  					    </div>
		  					    <div class="form-group">
		  					      <label class="col-xs-4 control-label no_padding_right">排序:</label>
		  					      <div class="col-xs-4">
		  					        <input class="form-control input_size save_home_order" name="order" placeholder="" type="text">
		  					      </div>
		  					    </div>
		  			        	<div class="form-group">
		  			    	      <div class="col-xs-12 text-center">
		  			    	      	<input type="hidden" name="bid">
		  			    	        <button type="button" id="addIndustryBanner" class="btn btn-primary "> 提 交 </button>
		  			    	      </div>
		  			    	    </div>
		  					</div>
		  					<div class="main-box">
		  						<h2></h2>
		  						<div id="gallery-photos-wrapper">
		  							<div class="form-horizontal" id="industryBannerList">
		  							</div>
		  						</div>
		  					</div>
		  				</div>
		  			</div>
		  	  	</div>

		  	  	<div class="tab-pane fade" id="interactive">
		  	    	<div class="panel panel-default">
		  				<div class="panel-body">
		  					<div class="form-horizontal">
		  						<div class="form-group">
		  					      <label class="col-xs-4 control-label no_padding_right">标题:</label>
		  					      <div class="col-xs-4 save_home_href">
		  					        <input class="form-control input_size save_home_href" name="title" placeholder="" type="text">
		  					      </div>
		  					    </div>
		  						<div class="form-group">
		  					      <label class="col-xs-4 control-label no_padding_right">简介:</label>
		  					      <div class="col-xs-4 save_home_href">
		  					        <input class="form-control input_size save_home_href" name="description" placeholder="" type="text">
		  					      </div>
		  					    </div>
		  					    <div class="form-group">
		  					      <label class="col-xs-4 control-label no_padding_right">链接:</label>
		  					      <div class="col-xs-4 save_home_href">
		  					        <input class="form-control input_size save_home_href" name="link" placeholder="" type="text">
		  					      </div>
		  					    </div>
		  					    <div class="form-group">
		  					      <label class="col-xs-4 control-label no_padding_right">图片:</label>
		  					      <div class="col-xs-4">
		  					            <input type="file" name="imgFile" class="uploadImage">
		  					            <input type="hidden" class="hiddenName" name="image" value="0">
		  					        	<span class="fileName"></span>
		  					      </div>
		  					    </div>
		  					    <div class="form-group">
		  					      <label class="col-xs-4 control-label no_padding_right">排序:</label>
		  					      <div class="col-xs-4">
		  					        <input class="form-control input_size save_home_order" name="order" placeholder="" type="text">
		  					      </div>
		  					    </div>
		  			        	<div class="form-group">
		  			    	      <div class="col-xs-12 text-center">
		  			    	      	<input type="hidden" name="bid">
		  			    	        <button type="button" id="addInteractiveBanner" class="btn btn-primary "> 提 交 </button>
		  			    	      </div>
		  			    	    </div>
		  					</div>
		  					<div class="main-box">
		  						<h2></h2>
		  						<div id="gallery-photos-wrapper">
		  							<div class="form-horizontal" id="interactiveBannerList">
		  							</div>
		  						</div>
		  					</div>
		  				</div>
		  			</div>
		  	  	</div>

			</div>
		</div>
	</div>
</div>


@include("admin.footer")

@include("admin.common")



<script type="text/html" id="indexBannerTemp">
{%each list as value}
<div class="row">
	<div class="form-group">
		<label class="col-xs-2 control-label no_padding_top ">链接:</label>
		<div class="col-xs-5 uc_value _left">
			{%value.link}
		</div>
	</div>
	<div class="form-group">
		<label class="col-xs-2 control-label no_padding_top ">排序:</label>
		<div class="col-xs-5 uc_value _left">
			{%value.order}
		</div>
	</div>
	<div class="form-group">
		<label class="col-xs-2 control-label no_padding_top ">图片:</label>
		<div class="col-xs-8 uc_value _left">
			<img src="<%url('images/ad')%>/{%value.image}" alt="..." class="img-thumbnail">
		</div>
	</div>
	<div class="form-group">
		<label class="col-xs-2 control-label no_padding_top ">操作:</label>
		<div class="col-xs-1 text-center">
		  <button type="button" id="" bid="{%value.id}" class="btn btn-primary editBanner">编辑</button>
		</div>
		<div class="col-xs-1 text-center">
		  <button type="button" id="" bid="{%value.id}" class="btn btn-warning delBanner">删除</button>
		</div>
	</div>
</div>
{%/each}
</script>

<script type="text/html" id="interactive_indexBannerTemp">
{%each list as value}
<div class="row">
	<div class="form-group">
		<label class="col-xs-2 control-label no_padding_top ">标题:</label>
		<div class="col-xs-5 uc_value _left">
			{%value.title}
		</div>
	</div>
	<div class="form-group">
		<label class="col-xs-2 control-label no_padding_top ">简介:</label>
		<div class="col-xs-5 uc_value _left">
			{%value.description}
		</div>
	</div>
	<div class="form-group">
		<label class="col-xs-2 control-label no_padding_top ">链接:</label>
		<div class="col-xs-5 uc_value _left">
			{%value.link}
		</div>
	</div>
	<div class="form-group">
		<label class="col-xs-2 control-label no_padding_top ">排序:</label>
		<div class="col-xs-5 uc_value _left">
			{%value.order}
		</div>
	</div>
	<div class="form-group">
		<label class="col-xs-2 control-label no_padding_top ">图片:</label>
		<div class="col-xs-8 uc_value _left">
			<img src="<%url('images/ad')%>/{%value.image}" alt="..." class="img-thumbnail">
		</div>
	</div>
	<div class="form-group">
		<label class="col-xs-2 control-label no_padding_top ">操作:</label>
		<div class="col-xs-1 text-center">
		  <button type="button" id="" bid="{%value.id}" class="btn btn-primary editBanner">编辑</button>
		</div>
		<div class="col-xs-1 text-center">
		  <button type="button" id="" bid="{%value.id}" class="btn btn-warning delBanner">删除</button>
		</div>
	</div>
</div>
{%/each}
</script>


<script type="text/javascript">
var url = "<%url('admin')%>/";
// var url = "http://192.168.2.107/tyw/public/admin/";
var que = que;
var burl = "advertis/add_index_banner";
var durl = "advertis/add_industry_banner";
var iurl = "advertis/add_interactive_banner";

$.getq(que, url + "advertis/get_index_banner", function (data){
	if(data.success){
		var html = template("indexBannerTemp", {list: data.data});
		$("#indexBannerList").html(html);
		$(".editBanner").bind("click", function(){
			var bid = $(this).attr("bid");
			$.get(url + "advertis/edit_index_banner", {bid : bid}, function (data){
				if(data.success){
					$("#home input[name = 'link']").val(data.data.link);
					$("#home input[name = 'image']").val(data.data.image);
					$("#home input[name = 'order']").val(data.data.order);
					$("#home input[name = 'bid']").val(data.data.id);
					burl = "advertis/update_index_banner";
				}
			})
		})

		$(".delBanner").bind("click", function(){
			var bid = $(this).attr("bid");
			$.post(url + "advertis/delete_index_banner", {bid : bid}, function(data){
				if(data.success){
					success("", "删除成功");
					setTimeout(function(){
						window.location.reload();
					},1000)
				}
			})
		})
	}
})


$(".uploadImage").AjaxFileUpload({

	// path : url + "upload",
	// path : "<% url('admin/upload') %>",

	path : url + "upload",
	// path : "<% url('/upload') %>",

	onComplete : function(filename){
			$(this).siblings(".hiddenName").val(filename.filename);
			$(this).siblings(".fileName").html(filename.filename);
		}
	});

$("#addIndexBanner").click(function(){
	var link = $("#home input[name = 'link']").val().trim();
	var image = $("#home input[name = 'image']").val().trim();
	var order = $("#home input[name = 'order']").val().trim();
	var bid = $("#home input[name = 'bid']").val().trim();

	if(link == "" || image == "" || order == ""){
		warning("不能为空！");
		return;
	}

	// var burl = "advertis/add_index_banner";

	$.post(url + burl,{
		link : link,
		image : image,
		order : order,
		bid : bid

	},function(data){
		if(data.success){
			success("","提交成功");
			setTimeout(function(){
				window.location.reload();
			},1000)
		}

	})
})



$("#showIndustry").click(function(){
	$.getq(que, url + "advertis/get_industry_banner", function (data){
		if(data.success){
			var html = template("indexBannerTemp", {list: data.data});
			$("#industryBannerList").html(html);
			$(".editBanner").bind("click", function(){
				var bid = $(this).attr("bid");
				$.get(url + "advertis/edit_industry_banner", {bid : bid}, function (data){
					if(data.success){
						$("#industry input[name = 'link']").val(data.data.link);
						$("#industry input[name = 'image']").val(data.data.image);
						$("#industry input[name = 'order']").val(data.data.order);
						$("#industry input[name = 'bid']").val(data.data.id);
						durl = "advertis/update_industry_banner";
					}
				})
			})

			$(".delBanner").bind("click", function(){
				var bid = $(this).attr("bid");
				$.post(url + "advertis/delete_index_banner", {bid : bid}, function(data){
					if(data.success){
						success("", "删除成功");
						setTimeout(function(){
							window.location.reload();
						},1000)
					}
				})
			})
		}
	})
})


$("#addIndustryBanner").click(function(){
	var link = $("#industry input[name = 'link']").val().trim();
	var image = $("#industry input[name = 'image']").val().trim();
	var order = $("#industry input[name = 'order']").val().trim();
	var bid = $("#industry input[name = 'bid']").val().trim();

	if(link == "" || image == "" || order == ""){
		warning("不能为空！");
		return;
	}

   // var durl = "advertis/add_industry_banner";
	$.post(url + durl,{
		link : link,
		image : image,
		order : order,
		bid : bid

	},function(data){
		if(data.success){
			success("","提交成功");
			setTimeout(function(){
				window.location.reload();
			},1000)
		}

	})
})


$("#showInteractive").click(function(){
	$.getq(que, url + "advertis/get_interactive_banner", function (data){
		if(data.success){
			var html = template("interactive_indexBannerTemp", {list: data.data});
			$("#interactiveBannerList").html(html);
			$(".editBanner").bind("click", function(){
				var bid = $(this).attr("bid");
				$.get(url + "advertis/edit_interactive_banner", {bid : bid}, function (data){
					if(data.success){
						$("#interactive input[name = 'title']").val(data.data.title);
						console.log(data.data.title)
						$("#interactive input[name = 'description']").val(data.data.description);
						$("#interactive input[name = 'link']").val(data.data.link);
						$("#interactive input[name = 'image']").val(data.data.image);
						$("#interactive input[name = 'order']").val(data.data.order);
						$("#interactive input[name = 'bid']").val(data.data.id);
						iurl = "advertis/update_interactive_banner";
					}
				})
			})

			$(".delBanner").bind("click", function(){
				var bid = $(this).attr("bid");
				$.post(url + "advertis/delete_index_banner", {bid : bid}, function(data){
					if(data.success){
						success("", "删除成功");
						setTimeout(function(){
							window.location.reload();
						},1000)
					}
				})
			})
		}
	})
})


$("#addInteractiveBanner").click(function(){
	var title = $("#interactive input[name = 'title']").val().trim();
	var description = $("#interactive input[name = 'description']").val().trim();
	var link = $("#interactive input[name = 'link']").val().trim();
	var image = $("#interactive input[name = 'image']").val().trim();
	var order = $("#interactive input[name = 'order']").val().trim();
	var bid = $("#interactive input[name = 'bid']").val().trim();

	if(link == "" || image == "" || order == "" || title == "" || description == ""){
		warning("不能为空！");
		return;
	}
	$.post(url + iurl,{
		title : title,
		description : description,
		link : link,
		image : image,
		order : order,
		bid : bid
	},function(data){
		if(data.success){
			success("","提交成功");
			setTimeout(function(){
				window.location.reload();
			},1000)
		}
	})
})

</script>



</body>
</html>